import ShaderLib from "../ShaderLib";

export default class PanScanShader {
    public static getVertexShader() {
        return ShaderLib.getDefaultVertexShader();
    }

    public static getFragmentShader() {
        let shader = `
            #include <common>
            #include <fog_pars_fragment>
            #include <logdepthbuf_pars_fragment>   
            varying vec2 uvTexcoord;
            uniform float radius;
            uniform float angle;
            uniform float axis;
            uniform vec3 v_color;

            void main(){  
  
                vec2 uv = uvTexcoord;
                float rad = atan(uv.y - 0.5, uv.x - 0.5);
                float theta = rad * 180.0 / PI;

                float subAxisTheta = (theta - axis);
                if( (subAxisTheta) < 0.0){
                    subAxisTheta = subAxisTheta + 360.0;
                }
                if ( (subAxisTheta<= angle) && (subAxisTheta >= 0.0) ) {
                    gl_FragColor= vec4(v_color, 1);
                }
                else
                {
                    discard;
                }
                #include <fog_fragment>
            }
        `;
        return shader;
    }

}
